#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "Stack.h"

bool isValid(char* s) {

    Stk st;
    Init(&st);

    while (*s != '\0')
    {
        if (*s == '(' || *s == '[' || *s == '{')
        {
            Push(&st, *s);
        }

        if (*s == ')' || *s == '[' || *s == '{')
        {
            char ch = Top(&st);
            if ((*s == ')' && ch != '(')
                || (*s == ']' && ch != '[')
                || (*s == '}' && ch != '{'))
                return false;
            Pop(&st);

        }

        s++;
    }

    if (!Empty(&st))
        return false;
    return true;
}

int main()
{
	/*Stk st;
	Init(&st);
	Push(&st, 1);
	Push(&st, 2);
	Push(&st, 3);
	Push(&st, 4);

	while (!Empty(&st))
	{
		printf("->%d ", Top(&st));
		Pop(&st);
	}

	Destory(&st);*/

    char str[] = "([)]" ;
    isValid(str);
	return 0;
}
